/*-
 * Public platform independent Near Field Communication (NFC) library
 *
 * Copyright (C) 2009, 2010 Roel Verdult
 * Copyright (C) 2010, 2011 Romain Tartière
 * Copyright (C) 2009, 2010, 2011 Romuald Conty
 *
 * This program is free software: you can redistribute it and/or modify it
 * under the terms of the GNU Lesser General Public License as published by the
 * Free Software Foundation, either version 3 of the License, or (at your
 * option) any later version.
 *
 * This program is distributed in the hope that it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for
 * more details.
 *
 * You should have received a copy of the GNU Lesser General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>
 *
 */

/**
 * @file uart.h
 * @brief UART driver header
 */

#ifndef __NFC_BUS_UART_H__
#  define __NFC_BUS_UART_H__

#  include <stdio.h>
#  include <string.h>
#  include <stdlib.h>


#  include "nfc-types.h"

// Define shortcut to types to make code more readable
typedef void *serial_port;
#  define INVALID_SERIAL_PORT (void*)(~1)
#  define CLAIMED_SERIAL_PORT (void*)(~2)
void    UART_init(void);
void    uart_open(void);
void    uart_close(void);

void    uart_set_speed(void);
uint32_t uart_get_speed(void);

int     uart_receive(uint8_t *pbtRx, const size_t szRx, void *abort_p, int timeout);
int     uart_send(const uint8_t *pbtTx, const size_t szTx, int timeout);
void USART1_WriteString(uint8_t *str);

char  **uart_list_ports(void);

#endif // __NFC_BUS_UART_H__
